#include <bits/stdc++.h>

#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T>inline void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T>inline void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

const int maxn = 200010;
mt19937_64 rnd(random_device{}());

int n, m, q, vis[maxn], ist[maxn], b[maxn], ins[maxn];
ull a[maxn], val[maxn], c[64];
pii ed[maxn];
vector<pii> e[maxn];

void add(ull x) {
  per (i, 63, 0) if (x >> i & 1) {
    if (!c[i]) return c[i] = x, void();
    x ^= c[i];
  }
}

ull qry(ull x) {
  per (i, 63, 0) chkmn(x, x ^ c[i]);
  return x;
}

void dfs(int u, int fa) {
  vis[u] = 1, ins[u] = 1;
  for (auto [v, id] : e[u]) {
    if (v == fa) continue;
    if (!vis[v]) {
      ist[id] = 1, dfs(v, u);
      a[u] ^= a[v], val[id] = a[v];
    } else if (ins[v]) {
      val[id] = rnd();
      a[u] ^= val[id], a[v] ^= val[id];
    }
  }
  ins[u] = 0;
}

int main() {
  freopen("graph.in", "r", stdin);
  freopen("graph.out", "w", stdout);
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  cin >> n >> m;
  rep (i, 1, m) {
    int u, v;
    cin >> u >> v;
    e[u].emplace_back(v, i);
    e[v].emplace_back(u, i);
    ed[i] = pii(u, v);
  }
  dfs(1, 0);
  cin >> q;
  while (q--) {
    int sz;
    cin >> sz;
    rep (i, 1, sz) cin >> b[i];
    rep (i, 0, 63) c[i] = 0;
    bool flag = 1;
    rep (i, 1, sz) flag &= (qry(val[b[i]]) != 0), add(val[b[i]]);
    cout << (flag ? "YES" : "NO") << '\n';
  }
}